package com.example.springclouddemo.demo;

import com.example.springclouddemo.conf.Haha;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@Component
@RequestMapping("demo")
public class Demo {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private Haha haha;

    @GetMapping("demo2")
    @ResponseBody
    public boolean getRes(){
        Boolean res = restTemplate.getForObject("http://127.0.0.1:8001/demo/getRes", Boolean.class);
        return res != null ? res : false;
        //return false;
    }

    @GetMapping("str")
    @ResponseBody
    public String getStr(){
        return "test";
    }

    @GetMapping("haha")
    @ResponseBody
    public String getHaha(){
        return haha.getStr();
    }

}
